/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package fr.ensisa.sunspot.event;

import java.util.Enumeration;
import java.util.Vector;

/**
 *
 * @author michel
 */
public class CompositeEvent extends AbstractEvent {

    private Vector<IEvent> events;

    public CompositeEvent () {
        super (IEvent.MAJOR_COMPOSITE, IEvent.MINOR_NO);
    }

    public Vector<IEvent> getEvents () {
        return events;
    }

    public void addEvent (IEvent event) {
        if (events == null) events = new Vector<IEvent> (3);
        events.addElement(event);
    }

    public String toString () {
        StringBuffer tmp = new StringBuffer ();
        tmp.append (super.toString());
        if (events == null) tmp.append("nothing");
        else {
            Enumeration<IEvent> e=events.elements();
            int i=0;
            while (e.hasMoreElements()) {
                tmp.append("[");
                tmp.append(i);
                tmp.append("[]=");
                tmp.append(e.nextElement().toString());
                tmp.append("\n\r");
                ++i;
            }
        }
        return tmp.toString();
    }

    public IEvent clone() {
        return null;
    }

}
